home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / drdobbs / 1987 / 04 / grglst1.lst < prev    next >
File List  |  1987-03-12  |  17KB  |  616 lines

  1. REM Mycin-like expert system for Amiga BASIC
  2. REM by Richard Grigonis
  3.  
  4. DIM AND.COMPONENT(12),AT.FACTOR.FOR.OR.COMPONENT(12)
  5. DIM OR.COMPONENT(12),TRAIL(30),HUMAN.INPUT$(4)
  6. DIM MESSAGE$(60),WHICH.EQ$(8),BLANK$(19)
  7. DIM HYPOTHESIS(20) ' CHANGE THIS NUMBER IF MORE THAN 20 ANIMALS
  8.  
  9. no=0:yes=1
  10. DATA 1,is an albatross
  11. albatross=1
  12. DATA 2,is a penguin
  13. penguin=2
  14. DATA 3,is an ostrich
  15. ostrich=3
  16. DATA 4,is a zebra
  17. zebra=4
  18. DATA 5,is a giraffe
  19. giraffe=5
  20. DATA 6,is a tiger
  21. tiger=6
  22. DATA 7,is a cheetah
  23. cheetah=7
  24. DATA 8,flies well
  25. flies.well=8
  26. DATA 9,swims
  27. swims=9
  28. DATA 10,is black and white
  29. black.and.white=10
  30. DATA 11,cannot fly
  31. cannot.fly=11
  32. DATA 12,has a long neck
  33. long.neck=12
  34. DATA 13,has black stripes
  35. black.stripes=13
  36. DATA 14,has long legs
  37. long.legs=14
  38. DATA 15,has dark spots
  39. dark.spots=15
  40. DATA 16,has a tawny color
  41. tawny.color=16
  42. DATA 17,is a bird
  43. bird=17
  44. DATA 18,is an ungulate
  45. ungulate=18
  46. DATA 19,is a carnivore
  47. carnivore=19
  48. DATA 20,is a mammal
  49. mammal=20
  50. DATA 21,has hair
  51. has.hair=21
  52. DATA 22,gives milk
  53. gives.milk=22
  54. DATA 23,eats meat
  55. eats.meat=23
  56. DATA 24,has pointed teeth and claws and forward pointing eyes
  57. teeth.claws.eyes=24
  58. DATA 25,is a mammal and has hoofs
  59. mammal.and.hoofs=25
  60. DATA 26,is a mammal and chews cud
  61. mammal.and.chews.cud=26
  62. DATA 27,has feathers
  63. feathers=27
  64. DATA 28,flies and lays eggs
  65. flies.and.lays.eggs=28
  66. DATA 29,lays eggs
  67. lays.eggs=29
  68. DATA 30,flies
  69. flies=30
  70. DATA 31,chews cud
  71. chews.cud=31
  72. DATA 32,has hoofs
  73. hoofs=32
  74. DATA 33,has forward pointing eyes
  75. front.eyes=33
  76. DATA 34,has claws
  77. claws=34
  78. DATA 35,has pointed teeth
  79. pointed.teeth=35
  80. DATA -1,END OF DATA
  81.  
  82. REM TOP-LEVEL HYPOTHESES (ROOTS) OF AND/OR TREE:
  83. HYPOTHESIS(1)=albatross
  84. HYPOTHESIS(2)=penguin
  85. HYPOTHESIS(3)=ostrich
  86. HYPOTHESIS(4)=zebra
  87. HYPOTHESIS(5)=giraffe
  88. HYPOTHESIS(6)=tiger
  89. HYPOTHESIS(7)=cheetah
  90. number.of.hypotheses=7
  91.  
  92. REM DETERMINE TOTAL NUMBER OF FACTS:
  93. number.of.facts=0
  94. WHILE fact <> -1
  95.   READ fact,MESSAGE$
  96.   number.of.facts=number.of.facts+1
  97. WEND
  98. number.of.facts=number.of.facts-1
  99. DIM BEEN.EXAMINED.BEFORE(number.of.facts),OUTPUT.CF(number.of.facts)
  100.  
  101. Start:
  102.   FOR A=0 TO UBOUND(OUTPUT.CF)
  103.     OUTPUT.CF(A)=0:BEEN.EXAMINED.BEFORE(A)=0
  104.   NEXT A
  105.   PRINT "I'm a backward-chaining expert system."
  106.   PRINT "Please think of one of the";number.of.hypotheses
  107.   PRINT "animals listed below.  I will ask you"
  108.   PRINT "questions about the animal and compute"
  109.   PRINT "the certainty of it being one"
  110.   PRINT "of the following";number.of.hypotheses;"animals:":PRINT
  111.   FOR fact=1 TO number.of.hypotheses
  112.     which.fact=HYPOTHESIS(fact)
  113.     GOSUB Find.message:PRINT "ANIMAL ";MESSAGE$
  114.   NEXT fact
  115.   PRINT
  116.  
  117. 10030 PRINT "DO YOU WANT: "
  118. PRINT "AN EXHAUSTIVE SEARCH (1) OR,"
  119. PRINT "STOP-ON-SUCCESS (2)? ":PRINT
  120. PRINT "Press the NUMBER of YOUR SELECTION"
  121. PRINT "and then press the RETURN KEY."
  122. halt.on.success=0:INPUT halt.on.success
  123. IF 0>halt.on.success OR halt.on.success>2
  124.    THEN PRINT "TRY AGAIN!":GOTO 10030
  125.  
  126. 10050 REM PROVE HYPOTHESES
  127. GOSUB Prove.albatross
  128. IF halt.on.success=2 AND OUTPUT.CF(albatross)=1 THEN 10165
  129. GOSUB Prove.penguin
  130. IF halt.on.success=2 AND OUTPUT.CF(penguin)=1 THEN 10165
  131. GOSUB Prove.ostrich
  132. IF halt.on.success=2 AND OUTPUT.CF(ostrich)=1 THEN 10165
  133. GOSUB Prove.zebra
  134. IF halt.on.success=2 AND OUTPUT.CF(zebra)=1 THEN 10165
  135. GOSUB Prove.giraffe
  136. IF halt.on.success=2 AND OUTPUT.CF(giraffe)=1 THEN 10165
  137. GOSUB Prove.tiger
  138. IF halt.on.success=2 AND OUTPUT.CF(tiger)=1 THEN 10165
  139. GOSUB Prove.cheetah
  140. IF halt.on.success=2 AND OUTPUT.CF(cheetah)=1 THEN 10165
  141.  
  142. 10165 REM DISPLAY RESULTS
  143. CLS
  144. PRINT "HERE ARE THE COMPUTED CERTAINTY FACTORS:"
  145. PRINT "(Correct animal has highest positive CF#)":PRINT
  146. FOR fact=1 TO number.of.hypotheses
  147.   which.fact=HYPOTHESIS(fact)
  148.   GOSUB Find.message
  149.   BLANK$=SPACE$(19)
  150.   MESSAGE$=MESSAGE$+MID$(BLANK$,1,LEN(BLANK$)-LEN(MESSAGE$))
  151.   PRINT "ANIMAL ";MESSAGE$;" CF=";OUTPUT.CF(which.fact)
  152. NEXT fact
  153. PRINT:PRINT "TO GO AGAIN, press the RETURN button."
  154. INPUT HUMAN.INPUT$:PRINT
  155. GOTO Start
  156.  
  157. REM SUBROUTINES TO COMPUTE CF'S (IN ALPHABETICAL ORDER)
  158. Compute.and.clause.cf:
  159.   GOSUB Find.lowest.cf.branch
  160.   GOSUB Multiply.lowest.cf.by.at.factor
  161.   GOSUB Trim.to.zero
  162.   OUTPUT.CF(TRAIL(depth))=new.cf
  163. RETURN
  164.  
  165. Compute.or.clause.cf:
  166.   GOSUB Multiply.component.cfs.by.at.factors
  167.   GOSUB Test.for.a.positive.number
  168.   GOSUB Run.or.equation
  169.   GOSUB Trim.to.zero
  170.   OUTPUT.CF(TRAIL(depth))=new.cf
  171. RETURN
  172.  
  173. Dec.stack:
  174.   depth=depth-1:RETURN
  175. Deduce:
  176.   which.fact=TRAIL(depth):GOSUB Find.message
  177.   PRINT:PRINT "The fact that the animal "
  178.   PRINT MESSAGE$;" (FACT # ";fact.number;")"
  179.   PRINT "Now has a Certainty Factor of: ";OUTPUT.CF(TRAIL(depth))
  180.   PRINT:GOSUB Dec.stack:GOSUB Delay
  181. RETURN
  182.  
  183. Delay:
  184.   FOR D=1 TO 10000:NEXT D:RETURN
  185. Explain.why:
  186.   which.fact=TRAIL(1):GOSUB Find.message:CLS
  187.   PRINT "I AM INVESTIGATING THE HYPOTHESIS"
  188.   PRINT "THAT THE ANIMAL..."
  189.   PRINT MESSAGE$;" (FACT # ";fact.number;")":PRINT
  190.   IF depth=1 THEN
  191.     PRINT "...BY FIRST ASKING YOU.":PRINT
  192.     PRINT "If you are not sure (-8 < CF < 8)"
  193.     PRINT "then I will investigate this hypothesis further."
  194.   ELSE
  195.     FOR A=2 TO depth
  196.       which.fact=TRAIL(A)
  197.       GOSUB Find.message:PRINT "...BY PROVING THAT THE ANIMAL..."
  198.       PRINT MESSAGE$;" (FACT # ";fact.number;")":PRINT
  199.     NEXT A
  200.     PRINT "...BY ASKING YOU."
  201.   END IF
  202.   PRINT:INPUT "PRESS RETURN KEY TO CONTINUE",HUMAN.INPUT$ 
  203. RETURN
  204.  
  205. Find.lowest.cf.branch:
  206.   lowest.number=OUTPUT.CF(AND.COMPONENT(1))
  207.   FOR branch=1 TO number.of.and.clause.components
  208.     number.to.test=OUTPUT.CF(AND.COMPONENT(branch))
  209.     IF lowest.number>number.to.test
  210.       THEN lowest.number=number.to.test
  211.   NEXT branch
  212. RETURN
  213.  
  214. Find.message:
  215.   RESTORE
  216.   FOR C=1 TO which.fact
  217.     READ fact.number, MESSAGE$
  218.   NEXT C
  219. RETURN
  220.  
  221. Inc.stack:
  222.   depth=depth+1:TRAIL(depth)=current.fact
  223. RETURN
  224.  
  225. Multiply.component.cfs.by.at.factors:
  226.   FOR branch=1 TO number.of.or.clause.components
  227.     new.cf=OUTPUT.CF(OR.COMPONENT(branch))
  228.      *AT.FACTOR.FOR.OR.COMPONENT(branch)
  229.     GOSUB Trim.to.zero
  230.     OUTPUT.CF(OR.COMPONENT(branch))=new.cf
  231.   NEXT branch
  232. RETURN
  233.  
  234. Multiply.lowest.cf.by.at.factor:
  235.   new.cf=lowest.number*at.factor.for.and.clause
  236. RETURN
  237.  
  238. Negative.or.equation:
  239.   new.cf=1
  240.   FOR branch=1 TO number.of.or.clause.components
  241.     new.cf=new.cf*(1+OUTPUT.CF(OR.COMPONENT(branch)))
  242.   NEXT branch
  243.   new.cf=-1+new.cf
  244. RETURN
  245.  
  246. Positive.or.equation:
  247.   new.cf=1
  248.   FOR branch=1 TO number.of.or.clause.components
  249.     new.cf=new.cf*(1-OUTPUT.CF(OR.COMPONENT(branch)))
  250.   NEXT branch
  251.   new.cf=1-new.cf
  252. RETURN
  253.  
  254. Run.or.equation:
  255.   IF WHICH.EQ$="POSITIVE" THEN
  256.     GOSUB Positive.or.equation
  257.   ELSE
  258.     GOSUB Negative.or.equation
  259.   END IF
  260. RETURN
  261.  
  262. Test.fact.for.human.input:
  263.   leave=no:GOSUB Inc.stack
  264.   IF BEEN.EXAMINED.BEFORE(current.fact)=yes THEN leave=yes:GOSUB
  265. Dec.stack:RETURN
  266.   BEEN.EXAMINED.BEFORE(current.fact)=yes
  267. 4156 which.fact=current.fact
  268.     GOSUB Find.message
  269. 4160 CLS:PRINT"(FACT # ";fact.number;")":PRINT
  270.     PRINT "ON A SCALE OF -10 TO 10 WHERE,"
  271.     PRINT " 10=absolutely certain it's true"
  272.     PRINT "  8=almost certain"
  273.     PRINT "  6=probably"
  274.     PRINT "  3=slight evidence"
  275.     PRINT "  0=unknown"
  276.     PRINT " -6=probably not"
  277.     PRINT " -8=almost certainly not"
  278.     PRINT "-10=definitely not"
  279.     PRINT:PRINT"TO WHAT DEGREE DO YOU BELIEVE THAT"
  280.     PRINT "The animal ";MESSAGE$;"?":PRINT   
  281.     PRINT "TYPE NUMBER AND PRESS RETURN KEY,"
  282.     PRINT "OR TYPE `why?' AND PRESS RETURN KEY"
  283.     INPUT HUMAN.INPUT$
  284.     HUMAN.INPUT$=UCASE$(HUMAN.INPUT$)
  285.     IF HUMAN.INPUT$="WHY" OR HUMAN.INPUT$="WHY?"
  286.       THEN GOSUB Explain.why:GOTO 4156
  287.     I=VAL(HUMAN.INPUT$)
  288.     IF -10>I OR I>10 THEN GOTO 4160
  289.     I=I/10:OUTPUT.CF(current.fact)=I
  290.     IF -.8>I OR I>.8 THEN leave=yes:GOSUB Deduce
  291. RETURN
  292.  
  293. Test.for.a.positive.number:
  294.   WHICH.EQ$="NEGATIVE"
  295.   FOR branch=1 TO number.of.or.clause.components
  296.     number.to.test=OUTPUT.CF(OR.COMPONENT(branch))
  297.     IF number.to.test>0 THEN
  298. WHICH.EQ$="POSITIVE":branch=number.of.or.clause.components
  299.   NEXT branch
  300. RETURN
  301.  
  302. Trim.to.zero:
  303.   IF -.2<=new.cf AND new.cf<=.2 THEN
  304.     new.cf=0
  305.   ELSEIF new.cf>=.8 THEN
  306.     new.cf=1
  307.   ELSEIF new.cf<=-.8 THEN
  308.     new.cf=-1
  309.   END IF
  310. RETURN
  311.  
  312. REM ***DEDUCTIVE ROUTINES FOLLOW***
  313. Prove.albatross:
  314.   current.fact=albatross:GOSUB Test.fact.for.human.input
  315.   IF leave=yes THEN RETURN
  316.   GOSUB Prove.bird:GOSUB Prove.flies.well
  317.     number.of.and.clause.components=2
  318.       AND.COMPONENT(1)=bird:AND.COMPONENT(2)=flies.well
  319.     at.factor.for.and.clause=1
  320.     GOSUB Compute.and.clause.cf
  321.   GOSUB Deduce
  322. RETURN
  323.  
  324. Prove.penguin:
  325.   current.fact=penguin:GOSUB Test.fact.for.human.input
  326.   IF leave=yes THEN RETURN
  327.   GOSUB Prove.bird:GOSUB Prove.cannot.fly
  328.   GOSUB Prove.black.and.white:GOSUB Prove.swims
  329.     number.of.and.clause.components=4
  330.       AND.COMPONENT(1)=bird:AND.COMPONENT(2)=cannot.fly
  331.       AND.COMPONENT(3)=black.and.white:AND.COMPONENT(4)=swims
  332.     at.factor.for.and.clause=.8
  333.     GOSUB Compute.and.clause.cf
  334.   GOSUB Deduce
  335. RETURN
  336.  
  337. Prove.ostrich:
  338.   current.fact=ostrich:GOSUB Test.fact.for.human.input
  339.   IF leave=yes THEN RETURN
  340.   GOSUB Prove.bird:GOSUB Prove.cannot.fly
  341.   GOSUB Prove.black.and.white:GOSUB Prove.long.neck
  342.     number.of.and.clause.components=4
  343.       AND.COMPONENT(1)=bird:AND.COMPONENT(2)=cannot.fly
  344.       AND.COMPONENT(3)=black.and.white:AND.COMPONENT(4)=long.neck
  345.     at.factor.for.and.clause=.85
  346.     GOSUB Compute.and.clause.cf
  347.   GOSUB Deduce
  348. RETURN
  349.  
  350. Prove.zebra:
  351.   current.fact=zebra:GOSUB Test.fact.for.human.input
  352.   IF leave=yes THEN RETURN
  353.   GOSUB Prove.ungulate:GOSUB Prove.black.stripes
  354.     number.of.and.clause.components=2
  355.       AND.COMPONENT(1)=ungulate:AND.COMPONENT(2)=black.stripes
  356.     at.factor.for.and.clause=.8
  357.     GOSUB Compute.and.clause.cf
  358.   GOSUB Deduce
  359. RETURN
  360.  
  361. Prove.giraffe:
  362.   current.fact=giraffe:GOSUB Test.fact.for.human.input
  363.   IF leave=yes THEN RETURN
  364.   GOSUB Prove.ungulate:GOSUB Prove.long.neck
  365.   GOSUB Prove.long.legs:GOSUB Prove.dark.spots
  366.     number.of.and.clause.components=4
  367.       AND.COMPONENT(1)=ungulate:AND.COMPONENT(2)=long.neck
  368.       AND.COMPONENT(3)=long.legs:AND.COMPONENT(4)=dark.spots
  369.     at.factor.for.and.clause=.85
  370.     GOSUB Compute.and.clause.cf
  371.   GOSUB Deduce
  372. RETURN
  373.  
  374. Prove.tiger:
  375.   current.fact=tiger:GOSUB Test.fact.for.human.input
  376.   IF leave=yes THEN RETURN
  377.   GOSUB Prove.mammal:GOSUB Prove.carnivore
  378.   GOSUB Prove.black.stripes:GOSUB Prove.tawny.color
  379.     number.of.and.clause.components=4
  380.       AND.COMPONENT(1)=mammal:AND.COMPONENT(2)=carnivore
  381.       AND.COMPONENT(3)=black.stripes:AND.COMPONENT(4)=tawny.color
  382.     at.factor.for.and.clause=.95
  383.     GOSUB Compute.and.clause.cf
  384.   GOSUB Deduce
  385. RETURN
  386.  
  387. Prove.cheetah:
  388.   current.fact=cheetah:GOSUB Test.fact.for.human.input
  389.   IF leave=yes THEN RETURN
  390.   GOSUB Prove.mammal:GOSUB Prove.carnivore
  391.   GOSUB Prove.tawny.color:GOSUB Prove.dark.spots
  392.     number.of.and.clause.components=4
  393.       AND.COMPONENT(1)=mammal:AND.COMPONENT(2)=carnivore
  394.       AND.COMPONENT(3)=tawny.color:AND.COMPONENT(4)=dark.spots
  395.     at.factor.for.and.clause=.95
  396.     GOSUB Compute.and.clause.cf
  397.   GOSUB Deduce
  398. RETURN
  399.  
  400. Prove.flies.well:
  401.   current.fact=flies.well:GOSUB Test.fact.for.human.input
  402.   IF leave=yes THEN RETURN
  403.   GOSUB Deduce
  404. RETURN
  405. Prove.swims:
  406.   current.fact=swims:GOSUB Test.fact.for.human.input
  407.   IF leave=yes THEN RETURN
  408.   GOSUB Deduce
  409. RETURN
  410.  
  411. Prove.black.and.white:
  412.   current.fact=black.and.white:GOSUB Test.fact.for.human.input
  413.   IF leave=yes THEN RETURN
  414.   GOSUB Deduce
  415. RETURN
  416.  
  417. Prove.cannot.fly:
  418.   current.fact=cannot.fly:GOSUB Test.fact.for.human.input
  419.   IF leave=yes THEN RETURN
  420.   GOSUB Deduce
  421. RETURN
  422.  
  423. Prove.long.neck:
  424.   current.fact=long.neck:GOSUB Test.fact.for.human.input
  425.   IF leave=yes THEN RETURN
  426.   GOSUB Deduce
  427. RETURN
  428.  
  429. Prove.black.stripes:
  430.   current.fact=black.stripes:GOSUB Test.fact.for.human.input
  431.   IF leave=yes THEN RETURN
  432.   GOSUB Deduce
  433. RETURN
  434.  
  435. Prove.long.legs:
  436.   current.fact=long.legs:GOSUB Test.fact.for.human.input
  437.   IF leave=yes THEN RETURN
  438.   GOSUB Deduce
  439. RETURN
  440.  
  441. Prove.dark.spots:
  442.   current.fact=dark.spots:GOSUB Test.fact.for.human.input
  443.   IF leave=yes THEN RETURN
  444.   GOSUB Deduce
  445. RETURN
  446.  
  447. Prove.tawny.color:
  448.   current.fact=tawny.color:GOSUB Test.fact.for.human.input
  449.   IF leave=yes THEN RETURN
  450.   GOSUB Deduce
  451. RETURN
  452.  
  453. Prove.bird:
  454.   current.fact=bird:GOSUB Test.fact.for.human.input
  455.   IF leave=yes THEN RETURN
  456.   GOSUB Prove.feathers:GOSUB Prove.flies.and.lays.eggs
  457.     number.of.or.clause.components=2
  458.       OR.COMPONENT(1)=feathers
  459.         AT.FACTOR.FOR.OR.COMPONENT(1)=1
  460.       OR.COMPONENT(2)=flies.and.lays.eggs
  461.         AT.FACTOR.FOR.OR.COMPONENT(2)=.8
  462.     GOSUB Compute.or.clause.cf
  463.   GOSUB Deduce
  464. RETURN
  465.  
  466. Prove.ungulate:
  467.   current.fact=ungulate:GOSUB Test.fact.for.human.input
  468.   IF leave=yes THEN RETURN
  469.   GOSUB Prove.mammal.and.hoofs
  470.   GOSUB Prove.mammal.and.chews.cud
  471.     number.of.or.clause.components=2
  472.       OR.COMPONENT(1)=mammal.and.hoofs:
  473.         AT.FACTOR.FOR.OR.COMPONENT(1)=.85
  474.       OR.COMPONENT(2)=mammal.and.chews.cud
  475.         AT.FACTOR.FOR.OR.COMPONENT(2)=.8
  476.     GOSUB Compute.or.clause.cf
  477.   GOSUB Deduce
  478. RETURN
  479.  
  480. Prove.carnivore:
  481.   current.fact=carnivore:GOSUB Test.fact.for.human.input
  482.   IF leave=yes THEN RETURN
  483.   GOSUB Prove.eats.meat:GOSUB Prove.teeth.claws.eyes
  484.     number.of.or.clause.components=2
  485.       OR.COMPONENT(1)=eats.meat
  486.         AT.FACTOR.FOR.OR.COMPONENT(1)=.85
  487.       OR.COMPONENT(2)=teeth.claws.eyes
  488.         AT.FACTOR.FOR.OR.COMPONENT(2)=1
  489.     GOSUB Compute.or.clause.cf
  490.   GOSUB Deduce
  491. RETURN
  492.  
  493. Prove.mammal:
  494.   current.fact=mammal:GOSUB Test.fact.for.human.input
  495.   IF leave=yes THEN RETURN
  496.   GOSUB Prove.has.hair:GOSUB Prove.gives.milk
  497.     number.of.or.clause.components=2
  498.       OR.COMPONENT(1)=has.hair:AT.FACTOR.FOR.OR.COMPONENT(1)=.85
  499.       OR.COMPONENT(2)=gives.milk:AT.FACTOR.FOR.OR.COMPONENT(2)=.8
  500.     GOSUB Compute.or.clause.cf
  501.   GOSUB Deduce
  502. RETURN
  503.  
  504. Prove.has.hair:
  505.   current.fact=has.hair:GOSUB Test.fact.for.human.input
  506.   IF leave=yes THEN RETURN
  507.   GOSUB Deduce
  508. RETURN
  509.  
  510. Prove.gives.milk:
  511.   current.fact=gives.milk:GOSUB Test.fact.for.human.input
  512.   IF leave=yes THEN RETURN
  513.   GOSUB Deduce
  514. RETURN
  515.  
  516. Prove.eats.meat:
  517.   current.fact=eats.meat:GOSUB Test.fact.for.human.input
  518.   IF leave=yes THEN RETURN
  519.   GOSUB Deduce
  520. RETURN
  521.  
  522. Prove.teeth.claws.eyes:
  523.   current.fact=teeth.claws.eyes:GOSUB Test.fact.for.human.input
  524.   IF leave=yes THEN RETURN
  525.   GOSUB Prove.pointed.teeth:GOSUB Prove.claws
  526.   GOSUB Prove.front.eyes
  527.     number.of.and.clause.components=3
  528.       AND.COMPONENT(1)=pointed.teeth:AND.COMPONENT(2)=claws
  529.       AND.COMPONENT(3)=front.eyes
  530.     at.factor.for.and.clause=.85
  531.     GOSUB Compute.and.clause.cf
  532.   GOSUB Deduce
  533. RETURN
  534.  
  535. Prove.mammal.and.hoofs:
  536.   current.fact=mammal.and.hoofs:GOSUB Test.fact.for.human.input
  537.   IF leave=yes THEN RETURN
  538.   GOSUB Prove.mammal:GOSUB Prove.hoofs
  539.     number.of.and.clause.components=2
  540.       AND.COMPONENT(1)=mammal:AND.COMPONENT(2)=hoofs
  541.     at.factor.for.and.clause=.8
  542.     GOSUB Compute.and.clause.cf
  543.   GOSUB Deduce
  544. RETURN
  545.  
  546. Prove.mammal.and.chews.cud:
  547.   current.fact=mammal.and.chews.cud:GOSUB Test.fact.for.human.input
  548.   IF leave=yes THEN RETURN
  549.   GOSUB Prove.mammal:GOSUB Prove.chews.cud
  550.     number.of.and.clause.components=2
  551.       AND.COMPONENT(1)=mammal:AND.COMPONENT(2)=chews.cud
  552.     at.factor.for.and.clause=.8
  553.     GOSUB Compute.and.clause.cf
  554.   GOSUB Deduce
  555. RETURN
  556.  
  557. Prove.feathers:
  558.   current.fact=feathers:GOSUB Test.fact.for.human.input
  559.   IF leave=yes THEN RETURN
  560.   GOSUB Deduce
  561. RETURN
  562.  
  563. Prove.flies.and.lays.eggs:
  564.   current.fact=flies.and.lays.eggs:GOSUB Test.fact.for.human.input
  565.   IF leave=yes THEN RETURN
  566.   GOSUB Prove.flies:GOSUB Prove.lays.eggs
  567.     number.of.and.clause.components=2
  568.       AND.COMPONENT(1)=flies:AND.COMPONENT(2)=lays.eggs
  569.     at.factor.for.and.clause=1
  570.     GOSUB Compute.and.clause.cf
  571.   GOSUB Deduce
  572. RETURN
  573.  
  574. Prove.lays.eggs:
  575.   current.fact=lays.eggs:GOSUB Test.fact.for.human.input
  576.   IF leave=yes THEN RETURN
  577.   GOSUB Deduce
  578. RETURN
  579.  
  580. Prove.flies:
  581.   current.fact=flies:GOSUB Test.fact.for.human.input
  582.   IF leave=yes THEN RETURN
  583.   GOSUB Deduce
  584. RETURN
  585.  
  586. Prove.chews.cud:
  587.   current.fact=chews.cud:GOSUB Test.fact.for.human.input
  588.   IF leave=yes THEN RETURN
  589.   GOSUB Deduce
  590. RETURN
  591.  
  592. Prove.hoofs:
  593.   current.fact=hoofs:GOSUB Test.fact.for.human.input
  594.   IF leave=yes THEN RETURN
  595.   GOSUB Deduce
  596. RETURN
  597.  
  598. Prove.front.eyes:
  599.   current.fact=front.eyes:GOSUB Test.fact.for.human.input
  600.   IF leave=yes THEN RETURN
  601.   GOSUB Deduce
  602. RETURN
  603.  
  604. Prove.claws:
  605.   current.fact=claws:GOSUB Test.fact.for.human.input
  606.   IF leave=yes THEN RETURN
  607.   GOSUB Deduce
  608. RETURN
  609.  
  610. Prove.pointed.teeth:
  611.   current.fact=pointed.teeth:GOSUB Test.fact.for.human.input
  612.   IF leave=yes THEN RETURN
  613.   GOSUB Deduce
  614. RETURN
  615.  
  616.